********************************************************************************
* Exporting table for multi-country COVID paper (BGD2 sample)
* last updated: 2020-10-12
* Salim Benhachmi
********************************************************************************

clear all
use "$da/BGD2", clear

********************************************************************************

* Drop in income
gen drop_inc = .
replace drop_inc = 0 if ec_q12_wage != . & ec_q15_pastmonth != .
replace drop_inc = 0 if ec_q18_monthprofit != . & ec_q21_profitlast != .
replace drop_inc = 1 if ec_q15_pastmonth < ec_q12_wage & ec_q12_wage != . & ///
	ec_q15_pastmonth != .
replace drop_inc = 1 if ec_q21_profitlast < ec_q18_monthprofit & ///
	ec_q18_monthprofit != . & ec_q21_profitlast != . 

* increase in income
gen incr_inc = .
replace incr_inc = 0 if ec_q12_wage != . & ec_q15_pastmonth != .
replace incr_inc = 0 if ec_q18_monthprofit != . & ec_q21_profitlast != .
replace incr_inc = 1 if ec_q15_pastmonth > ec_q12_wage & ec_q12_wage != . & ///
	ec_q15_pastmonth != .
replace incr_inc = 1 if ec_q21_profitlast > ec_q18_monthprofit & ///
	ec_q18_monthprofit != . & ec_q21_profitlast != . 

********************************************************************************

keep if covid_sample == 1

svyset cluster2 [pw=hh_weight_covid], singleunit(scaled)

local indicators drop_inc incr_inc

foreach ind of local indicators {
	svy: mean `ind'
	matrix b = r(table)
	loc mean_`ind' : di %10.2fc b[1,1]
}

loc ratio = round(`mean_drop_inc' / `mean_incr_inc', 0.1)

clear
set obs 1

gen drop_inc = "`mean_drop_inc'"
gen incr_inc = "`mean_incr_inc'"
gen ratio = "`ratio'"

export excel using "$dtab/Inverse Table.xlsx", sheetmodify cell(B7)

********************************************************************************
